﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DoctorWorkDayManager.aspx.cs" Inherits="RegisterWeb.Manager.DoctorWorkDayManager.DoctorWorkDayManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>

<script type="text/javascript">

    var url; //提交数据的路径
    var formId; //当天要提交的Form的编号
    var dialogId; //对话框的编号

    var successCallback = function (result) {
        //result为请求处理后的返回值
        var result = eval('(' + result + ')');
        if (result.success) {
            $.messager.show({
                title: 'Success',
                msg: result.msg
            });
            $(dialogId).dialog('close');
            $('#dg').datagrid('reload');
        } else {
            $.messager.show({
                title: 'Error',
                msg: result.msg
            });
        }
    }

    $(function () {
        //预加载编辑框
        $("#addDoctorWorkDay").dialog({
            "title": "编辑医生在职日期信息",
            width: 600,
            height: 400,
            href: 'EditDoctorWorkDay.aspx'
        });
        $("#addDoctorWorkDay").dialog('open').dialog('close');

        $('#dg').datagrid({

            onDblClickRow: function (rowIndex, rowData) {
                $('#addDoctorWorkDay').dialog('open');
                $('#Doctor_Name').combobox('setValue', rowData.Doctor_ID);
                $('#Type').combobox('setValue', rowData.TimeType);
                $("#DayTime").datebox('setValue', rowData.DayTime);

                url = 'ashx/DoctorWorkDayManagerService.ashx?action=edit&id=' + rowData.ID;
                formId = "#add";
                dialogId = "#addDoctorWorkDay";

            }
        });

    });
    //编辑医生在职日期部分
    function editDoctorWorkDay() {

        var row = $('#dg').datagrid('getSelected');

        if (row) {

            $('#addDoctorWorkDay').dialog('open');
            $('#Doctor_Name').combobox('setValue', row.Doctor_ID);
            $('#Type').combobox('setValue', row.TimeType);
            $("#DayTime").datebox('setValue', row.DayTime);

            url = 'ashx/DoctorWorkDayManagerService.ashx?action=edit&id=' + row.ID;
            formId = "#add";
            dialogId = "#addDoctorWorkDay";
        }
        else {
            $.messager.alert("提示", "您没有选中任何行！");
        }
    }

    //添加医生在职日期部分
    function addDoctorWorkDay() {
        $("#addDoctorWorkDay").dialog('refresh');
        $("#addDoctorWorkDay").dialog({
            "title": "添加医生在职日期",
            width: 600,
            height: 400,
            href: 'AddDoctorWorkDay.aspx'
        });
        $('#addDoctorWorkDay').dialog('open');
        $('#add').form('clear');

        url = 'ashx/DoctorWorkDayManagerService.ashx?action=add';
        formId = "#add";
        dialogId = "#addDoctorWorkDay";

    }
    function saveInfo() {
        $(formId).form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: successCallback
        });
    }

    //  删除代码部分
    function deleteDoctorWorkDay() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('删除提示', '确定要删除' + '"' + row.ID + '"' + '吗', function (r) {
                if (r) {
                    $.post('ashx/DoctorWorkDayManagerService.ashx', { id: row.ID, action: 'delete' }, function (data, State) {
                        if (data == "ok") {
                            $('#dg').datagrid('reload');
                        } else {
                            $.messager.show({
                                title: 'Error',
                                msg: '删除该医生在职日期失败!'
                            });
                        }
                    });
                }
            });
        }
    }

    function check() {
        var value = $("#Title").val();
        if (value != "") {
            $.post('ashx/DoctorWorkDayManagerService.ashx', { action: 'check', name: value }, function (data, State) {
                if (data == 'ok') {
                    $("#Title").val("");
                }
                else {
                    $("#error").text("");
                }
            });
        }
    }

    //多条件查询方法
    function tsearch() {
        var TimeType = $("#MyType").combobox("getValue");
        var Doctor_ID = $("#MyDoctor_Name").combobox("getValue");
        var Begin = $("#Begin").datebox("getValue");
        var End = $("#End").datebox("getValue");
        $('#dg').datagrid('options').pageNumber = 1;
        $('#dg').datagrid('getPager').pagination({ pageNumber: 1 });
        $('#dg').datagrid('options').url = 'ashx/DoctorWorkDayManagerService.ashx?action=search&TimeType=' + TimeType + '&Doctor_ID=' + Doctor_ID + '&Begin=' + Begin + '&End=' + End;
        $('#dg').datagrid("reload");
    }

</script>

</head>
<body>
    <form id="form1">
    <div region="center" title="医生在职日期管理" >
<table id="dg" title="医生在职日期管理" class="easyui-datagrid" style="overflow:auto; height:550px"
			url="ashx/DoctorWorkDayManagerService.ashx?action=list"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true"   idField='ID'
            pageSize="20"
            >
		<thead>
			<tr>
				<th field="ID" width="50">编号</th>
				<th field="Doctor_Name" width="50">医生</th>
                <th field="Doctor_ID" width="50" hidden='true'>医生</th>
				<th field="TimeType" width="50" hidden='true'>类型</th>
                <th field="TextTimeType" width="50">类型</th>
				<th field="DayTime" width="50">在职日期</th>
                <th field="Recoder" width="50">记录人</th>
                <th field="AddTime" width="50">添加时间</th>
			</tr>
		</thead>
	</table>

    <div id="toolbar" style="padding:5px;height:auto">
					<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addDoctorWorkDay()">添加医生在职日期</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editDoctorWorkDay()">编辑医生在职日期</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteDoctorWorkDay()">删除医生在职日期</a>
    


			<div id="addDoctorWorkDay" class="easyui-dialog" closed="true" buttons="#addDoctorWorkDay-buttons" style="padding:10px 20px">
        	</div>
			<div id="addDoctorWorkDay-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#addDoctorWorkDay').dialog('close')">关闭</a>
			</div>

            <div>
			在职时间: <input class="easyui-datebox" style="width:80px" id="Begin">
			到: <input class="easyui-datebox" style="width:80px" id="End">
            
			医生姓名: 
			<select name="MyDoctor_Name" id="MyDoctor_Name" style="width:150px;">
            </select>
              <script type="text/javascript">

                  $('#MyDoctor_Name').combobox({
                      url: 'ashx/DoctorWorkDayManagerService.ashx?action=Name',
                      valueField: 'Doctor_ID',
                      textField: 'Doctor_Name',
                      panelHeight: "auto"
                  });
             
            </script>

			时间类型: 
			<select name="MyType" id="MyType" style="width:150px;">
            </select>
              <script type="text/javascript">

                  $('#MyType').combobox({
                      url: 'ashx/DoctorWorkDayManagerService.ashx?action=Type',
                      valueField: 'SystemParameter_ID',
                      textField: 'SystemParameter_Name',
                      panelHeight: "auto"
                  });
             
            </script>
            
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="tsearch()">查询</a>
		</div>
        </div>
    </div>
    </form>
</body>
</html>
